import java.math.BigInteger;

public class JInteger implements Integer {

  public JInteger (String src) throws Exception { _ref = new BigInteger(src); }

  @Override
  public void release () throws Exception { _ref = null; }

  @Override
  public int cmp (Integer other) throws Exception { return _ref.compareTo(((JInteger)other)._ref); }

  @Override
  public Integer add (Integer other) throws Exception { return new JInteger(_ref.add(((JInteger)other)._ref)); }

  @Override
  public Integer sub (Integer other) throws Exception { return new JInteger(_ref.subtract(((JInteger)other)._ref)); }

  @Override
  public Integer mul (Integer other) throws Exception { return new JInteger(_ref.multiply(((JInteger)other)._ref)); }

  @Override
  public Integer div (Integer other) throws Exception { return new JInteger(_ref.divide(((JInteger)other)._ref)); }

  @Override
  public Integer mod (Integer other) throws Exception { return new JInteger(_ref.mod(((JInteger)other)._ref)); }

  @Override
  public Integer neg () throws Exception { return new JInteger(_ref.negate()); }

  @Override
  public Integer abs () throws Exception { return new JInteger(_ref.abs()); }

  @Override
  public Integer pow (int exp) throws Exception { return new JInteger(_ref.pow(exp)); }

  @Override
  public Meta meta () throws Exception {
    Meta meta = new Meta();
    meta.sign = _ref.signum();
    meta.value = _ref.toString();
    return meta;
  }


  private JInteger (BigInteger ref) { _ref = ref; }

  private BigInteger _ref;
}
